package com.service.device;

import com.common.ErrorCodeEnum;
import com.common.emums.DataStatus;
import com.common.exception.BusinessException;
import com.common.utils.StringUtils;
import com.core.springSecurity.common.SecurityUtils;

import com.dao.secondary.device.DevicePcbBjBaseInfoMapper;
import com.model.domain.device.GetDevicePcbBjBaseInfoDO;
import com.model.pojo.device.DevicePcbBjBaseInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;



/**
 * @Author: zql
 * @Description: 安卓版北京设备基础信息服务
 * @Data: 2024-03-15
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DevicePcbBjBaseInfoService {
    private final DevicePcbBjBaseInfoMapper devicePcbBjBaseInfoMapper;
    public List<DevicePcbBjBaseInfo> getPageList(GetDevicePcbBjBaseInfoDO getDevicePcbBjBaseInfoDO){
        PageHelper.clearPage();
        PageHelper.startPage(getDevicePcbBjBaseInfoDO.getPage(),getDevicePcbBjBaseInfoDO.getPageSize(),getDevicePcbBjBaseInfoDO.getSortRow()+getDevicePcbBjBaseInfoDO.getSortOrder());
        return devicePcbBjBaseInfoMapper.selectList(getDevicePcbBjBaseInfoDO);
    }
    public List<DevicePcbBjBaseInfo> getAllList(GetDevicePcbBjBaseInfoDO getDevicePcbBjBaseInfoDO){
        PageHelper.clearPage();
        return devicePcbBjBaseInfoMapper.selectList(getDevicePcbBjBaseInfoDO);
    }

    public int save(DevicePcbBjBaseInfo info){
        info.setCreatedTime(new Date());
        return devicePcbBjBaseInfoMapper.insertSelective(info);
    }

    public int update(DevicePcbBjBaseInfo info){
        info.setLastModifiedTime(new Date());
        return devicePcbBjBaseInfoMapper.updateByPrimaryKeySelective(info);
    }
    public void updateList(List<DevicePcbBjBaseInfo> list){
        devicePcbBjBaseInfoMapper.updateListSelective(list);
    }

    public DevicePcbBjBaseInfo getByDtu(String dtu){
        return devicePcbBjBaseInfoMapper.selectByDtu(dtu);
    }
    public DevicePcbBjBaseInfo getBySim(String sim){
        return devicePcbBjBaseInfoMapper.selectBySim(sim);
    }
}
